// import type { Equal } from '@type-challenges/utils'
// export type KebabCase<S,U extends string =""> = 
// S extends `${infer First}${infer Rest}`
//     ?Equal<First,`-`> extends true
//         ?KebabCase<Rest,`${U}${First}`>
//         :Uppercase<First> extends Lowercase<First>
//             ?KebabCase<Rest,`${U}${First}`>
//             :KebabCase<Rest,`${U}-${Lowercase<First>}`>
//         :U extends `${infer L}${infer R}`
//         ?L extends `-`
//             ?R
//             :U
//         :never
type KebabCase<S extends string, IsR = false> =
S extends `${infer F}${infer Rest}`
  ? Uppercase<F> extends Lowercase<F> ?
    `${F}${KebabCase<Rest, true>}`
    : `${Uppercase<F> extends F ? IsR extends true ? '-' : '' : ''}${Uppercase<F> extends F ? Lowercase<F> : F}${KebabCase<Rest, true>}`
  : S;


//   type Test<F extends string> = Uppercase<F> extends Lowercase<F>?true:false
//   type t =Test<'-'>
// type t = KebabCase<'foo-bar'>
